﻿using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace ZenSystemService.Api.Migrations
{
    /// <inheritdoc />
    public partial class TrainingReport : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "TrainingReports",
                columns: table => new
                {
                    TrainingReportId = table.Column<int>(type: "int", nullable: false)
                        .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
                    Sequence = table.Column<int>(type: "int", nullable: false),
                    TraineeId = table.Column<int>(type: "int", nullable: false),
                    CourseId = table.Column<int>(type: "int", nullable: false),
                    TrainingItemId = table.Column<int>(type: "int", nullable: false),
                    ReportContent = table.Column<string>(type: "longtext", nullable: true)
                        .Annotation("MySql:CharSet", "utf8mb4")
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_TrainingReports", x => x.TrainingReportId);
                    table.ForeignKey(
                        name: "FK_TrainingReports_Courses_CourseId",
                        column: x => x.CourseId,
                        principalTable: "Courses",
                        principalColumn: "CourseId",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_TrainingReports_TrainingItems_TrainingItemId",
                        column: x => x.TrainingItemId,
                        principalTable: "TrainingItems",
                        principalColumn: "TrainingItemId",
                        onDelete: ReferentialAction.Cascade);
                    table.ForeignKey(
                        name: "FK_TrainingReports_Users_TraineeId",
                        column: x => x.TraineeId,
                        principalTable: "Users",
                        principalColumn: "UserId",
                        onDelete: ReferentialAction.Cascade);
                })
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateIndex(
                name: "IX_TrainingReports_CourseId",
                table: "TrainingReports",
                column: "CourseId");

            migrationBuilder.CreateIndex(
                name: "IX_TrainingReports_TraineeId",
                table: "TrainingReports",
                column: "TraineeId");

            migrationBuilder.CreateIndex(
                name: "IX_TrainingReports_TrainingItemId",
                table: "TrainingReports",
                column: "TrainingItemId");
        }

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "TrainingReports");
        }
    }
}
